﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SetAlarm.aspx.cs" Inherits="iEN.Alarm.SetAlarm" %>
<%@ Register src="../UserControl/TopMenu.ascx" tagname="TopMenu" tagprefix="uc2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>告警設定</title>
</head>
<body>
    <form id="form1" runat="server">
    <center>
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
        </div>
        <table style="width: 952px" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
            <tr>
                <td>
                    <uc2:TopMenu ID="TopMenu1" runat="server" />
                </td>
            </tr>
            <tr>
            <td style="background-image:url('../images/title_back.gif')" align="center" ; width="952px" >
                    <asp:Label ID="Label1" runat="server" Text="告警設定" BackColor="Transparent" style="color:Blue;background-color:Transparent;font-family:微軟正黑體,新細明體,標楷體,Arial,sans-serif;font-size:XX-Large;"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <asp:Label ID="lblMsg" runat="server" Font-Names="微軟正黑體" Font-Size="X-Large"  ForeColor="Red" Text="你沒有瀏覽此頁面的權限" Visible="False"></asp:Label>
                    <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                        <ContentTemplate>
                            <asp:ImageButton ID="imgTip" runat="server" ImageUrl="~/images/info_show.gif" OnClick="imgTip_Click"
                                ToolTip="按我顯示或隱藏設定說明"/>
                            <asp:Panel ID="Panel2" runat="server" BackColor="#FFFFC0" GroupingText="告警設定說明" Width="800px"
                                Visible="False">
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/images/flag.gif" /><asp:Label ID="Label2"
                                    runat="server" Font-Size="10pt" ForeColor="Blue" Text="請先設定各宿舍大樓標準用電度數"></asp:Label><br />
                                <asp:Image ID="Image3" runat="server" ImageUrl="~/images/flag.gif" /><asp:Label ID="Label5"
                                    runat="server" Font-Size="10pt" ForeColor="Blue" Text="再設定各宿舍大樓寢室用電告警值(%)"></asp:Label><br />
                                <asp:Image ID="Image2" runat="server" ImageUrl="~/images/flag.gif" /><asp:Label ID="Label6"
                                    runat="server" Font-Size="10pt" ForeColor="Blue" Text="最後設定各宿舍大樓寢室的告警群組"></asp:Label>
                                    </asp:Panel>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" >
                        <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1">
                            <HeaderTemplate>
                                設定大樓標準用電度數
                            </HeaderTemplate>
                            <ContentTemplate>

                                <asp:Panel ID="Panel4" runat="server" BackColor="PowderBlue" GroupingText="宿舍大樓列表" Width="600px"
                                    Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                    <ContentTemplate>
                                        
                                        <asp:GridView ID="gvAlarmBuilding" runat="server" BackColor="White" BorderColor="#336666"
                                            BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal"
                                            AutoGenerateColumns="False" Width="580px" EmptyDataText="查無相關資料..." Font-Bold="False"
                                            Font-Size="15px" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif"
                                            DataSourceID="AlarmBuildingDataSource"
                                            OnRowCommand="gvAlarmBuilding_RowCommand"
                                            OnRowUpdated="gvAlarmBuilding_RowUpdated"
                                            DataKeyNames="_id"
                                            HorizontalAlign="Center" AllowPaging="False" AllowSorting="False">
                                            <RowStyle BackColor="White" ForeColor="#333333" />
                                            <Columns>
                                                
                                                <asp:BoundField DataField="_name" HeaderText="大樓名稱" SortExpression="_name" ReadOnly="True">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="_desc" HeaderText="大樓描述" SortExpression="_desc" ReadOnly="True">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="_value" HeaderText="用電基準值(kwh)" SortExpression="_value">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:CommandField ShowEditButton="True" />
                                               
                                            </Columns>
                                            <HeaderStyle BackColor="#ADE6ED" Font-Names="42" Font-Size="10pt" ForeColor="Teal"
                                                HorizontalAlign="Center" />
                                            <PagerSettings Position="TopAndBottom" />
                                            <PagerStyle BackColor="#ADE6ED" Font-Size="10pt" ForeColor="Blue" HorizontalAlign="Center" />
                                            <AlternatingRowStyle BackColor="Azure" />
                                            <EmptyDataTemplate>
                                                <table>
                                                    <tr>
                                                        <td style="font-size: 20; color: Red;">
                                                            無宿舍大樓資料...
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EmptyDataTemplate>
                                        </asp:GridView>
                                        <asp:ObjectDataSource ID="AlarmBuildingDataSource" runat="server" 
                                            SelectMethod="getAlarmBuildingTable" TypeName="DataAccess.DBAccess" 
                                            UpdateMethod="updateAlarmBuilding">
                                            <UpdateParameters>
                                                <asp:Parameter Name="_id" />
                                            </UpdateParameters>
                                        </asp:ObjectDataSource>
                                    </ContentTemplate>
                                </asp:UpdatePanel>

                                </asp:Panel>
                            </ContentTemplate>                        
                        </cc1:TabPanel>
                        <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel1">
                            <HeaderTemplate>
                                設定寢室告警值
                            </HeaderTemplate>
                            <ContentTemplate>
                                <asp:Panel ID="Panel1" runat="server" BackColor="PowderBlue" GroupingText="各大樓寢室列表" Width="600px"
                                    Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                        <img src="../images/dot01.gif" /><asp:Label ID="Label8" runat="server" ForeColor="Black"
                                            Text="選擇宿舍大樓："></asp:Label>
                                        <asp:DropDownList ID="ddlAlarmBuilding" runat="server" AutoPostBack="True" Width="144px"
                                            OnDataBound="ddlAlarmBuilding_DataBound" OnSelectedIndexChanged="ddlAlarmBuilding_SelectedIndexChanged">
                                        </asp:DropDownList>
                                        <asp:GridView ID="gvAlarmDormitory" runat="server" BackColor="White" BorderColor="#336666"
                                            BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal"
                                            AutoGenerateColumns="False" Width="580px" EmptyDataText="查無相關資料..." Font-Bold="False"
                                            Font-Size="15px" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif"
                                            DataSourceID="AlarmDormitoryDataSource"
                                            OnRowCommand="gvAlarmDormitory_RowCommand"
                                            OnRowUpdating="gvAlarmDormitory_RowUpdating"
                                            OnRowUpdated="gvAlarmDormitory_RowUpdated"
                                            DataKeyNames="_id"
                                            HorizontalAlign="Center" AllowPaging="False" AllowSorting="False">
                                            <RowStyle BackColor="White" ForeColor="#333333" />
                                            <Columns>
                                                
                                                <asp:BoundField DataField="_name" HeaderText="寢室名稱" SortExpression="_name" ReadOnly="True">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="_desc" HeaderText="寢室描述" SortExpression="_desc" ReadOnly="True">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="_value" HeaderText="告警值(%)" SortExpression="_value">
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:BoundField>
                                                <asp:TemplateField HeaderText="啟用">
                                                    <EditItemTemplate>
                                                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("_enabled") %>' />
                                                    </EditItemTemplate>
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("_enabled") %>'
                                                            Enabled="False" />
                                                    </ItemTemplate>
                                                    <ItemStyle HorizontalAlign="Center" />
                                                </asp:TemplateField>
                                                <asp:CommandField ShowEditButton="True" />
                                               
                                            </Columns>
                                            <HeaderStyle BackColor="#ADE6ED" Font-Names="42" Font-Size="10pt" ForeColor="Teal"
                                                HorizontalAlign="Center" />
                                            <PagerSettings Position="TopAndBottom" />
                                            <PagerStyle BackColor="#ADE6ED" Font-Size="10pt" ForeColor="Blue" HorizontalAlign="Center" />
                                            <AlternatingRowStyle BackColor="Azure" />
                                            <EmptyDataTemplate>
                                                <table>
                                                    <tr>
                                                        <td style="font-size: 20; color: Red;">
                                                            無寢室資料...
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EmptyDataTemplate>
                                        </asp:GridView>
                                        <asp:ObjectDataSource ID="AlarmDormitoryDataSource" runat="server" 
                                            SelectMethod="getAlarmDormitoryTable" TypeName="DataAccess.DBAccess" 
                                            UpdateMethod="updateAlarmDormitory">
                                            <SelectParameters>
                                                <asp:SessionParameter Name="_parent_id" SessionField="_parent_id" />
                                            </SelectParameters>
                                            <UpdateParameters>
                                                <asp:Parameter Name="_id" />
                                                <asp:SessionParameter Name="_enabled" SessionField="_enabled" />
                                            </UpdateParameters>
                                        </asp:ObjectDataSource>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                                </asp:Panel>
                            </ContentTemplate>
                        </cc1:TabPanel>
                        <cc1:TabPanel ID="TabPanel4" runat="server" HeaderText="TabPanel1">
                            <HeaderTemplate>
                                設定寢室告警群組
                            </HeaderTemplate>
                            <ContentTemplate>
                            <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                    <ContentTemplate>
                                <asp:Panel ID="Panel3" runat="server" BackColor="PowderBlue" GroupingText="寢室告警群組設定"
                                    Width="700px" Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                    <img src="../images/dot01.gif" /><asp:Label ID="Label4" runat="server" ForeColor="Black"
                                        Text="選擇宿舍大樓："></asp:Label><asp:DropDownList ID="ddlAlarmBuilding2" runat="server" AutoPostBack="True"
                                            OnDataBound="ddlAlarmBuilding2_DataBound" OnSelectedIndexChanged="ddlAlarmBuilding2_SelectedIndexChanged"
                                            ValidationGroup="None">
                                        </asp:DropDownList>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlAlarmBuilding2"
                                        CssClass="note" Display="Dynamic" ErrorMessage="(必需有資料)" ValidationGroup="valSet"></asp:RequiredFieldValidator>
                                    <br />
                                    
                                    <img src="../images/dot01.gif" /><asp:Label ID="Label13" runat="server" ForeColor="Black"
                                        Text="選擇寢室："></asp:Label><asp:DropDownList ID="ddlAlarmDormitory" runat="server" AutoPostBack="True"
                                            OnDataBound="ddlAlarmDormitory_DataBound" OnSelectedIndexChanged="ddlAlarmDormitory_SelectedIndexChanged"
                                            ValidationGroup="None">
                                        </asp:DropDownList>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddlAlarmDormitory"
                                        CssClass="note" Display="Dynamic" ErrorMessage="(必需有資料)" ValidationGroup="valSet"></asp:RequiredFieldValidator>
                                    <br />
                                    <img src="../images/dot01.gif" /><asp:Label ID="Label3" runat="server" ForeColor="Black"
                                        Text="選擇告警群組："></asp:Label>
                                    <asp:DropDownList ID="ddlAlarmGrp" runat="server" AutoPostBack="True" Width="144px"
                                        OnDataBound="ddlAlarmGrp_DataBound" OnSelectedIndexChanged="ddlAlarmGrp_SelectedIndexChanged">
                                    </asp:DropDownList>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlAlarmGrp"
                                        CssClass="note" Display="Dynamic" ErrorMessage="(必需有資料)" ValidationGroup="valSet"></asp:RequiredFieldValidator>
                                    <br />
                                    <asp:Button ID="btnSet" runat="server" CssClass="graybtn" OnClick="btnSet_Click"
                                        Text="新增" ValidationGroup="valSet" /><asp:Label ID="lblInfo" runat="server" ForeColor="Red"></asp:Label>
                                </asp:Panel>
                                        <br>
                                </br>
                                <asp:Panel ID="Panel7" runat="server" BackColor="PowderBlue" GroupingText="寢室告警群組列表"
                                            Width="700px" Font-Size="15px" ForeColor="Black" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif">
                                    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                        <ContentTemplate>
                                            <asp:GridView ID="gvAlarmDormitoryGrp" runat="server" BackColor="White" BorderColor="#336666"
                                                BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal"
                                                AutoGenerateColumns="False" Width="680px" EmptyDataText="查無相關資料..." Font-Bold="False"
                                                Font-Size="15px" Font-Names="微軟正黑體,新細明體,標楷體,Arial,sans-serif" OnRowCommand="gvAlarmDormitoryGrp_RowCommand"
                                                HorizontalAlign="Center" AllowPaging="False" AllowSorting="False">
                                                <RowStyle BackColor="White" ForeColor="#333333" />
                                                <Columns>
                                                    <asp:BoundField DataField="dormitoryName" HeaderText="寢室名稱" SortExpression="dormitoryName">
                                                        <ItemStyle HorizontalAlign="Center" />
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="dormitoryDesc" HeaderText="寢室描述" SortExpression="dormitoryDesc">
                                                        <ItemStyle HorizontalAlign="Center" />
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="groupName" HeaderText="告警群組" SortExpression="groupName">
                                                        <ItemStyle HorizontalAlign="Center" />
                                                    </asp:BoundField>
                                                    <asp:TemplateField ShowHeader="False">
                                                        <ItemTemplate>
                                                            <asp:Button ID="btnDelAlarmDormitoryGrp" runat="server" CausesValidation="false" CommandName="Del"
                                                                OnClientClick="return confirm('確定要刪除??');" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                                                                Text="刪除" />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                                <HeaderStyle BackColor="#ADE6ED" Font-Names="42" Font-Size="10pt" ForeColor="Teal"
                                                    HorizontalAlign="Center" />
                                                <PagerSettings Position="TopAndBottom" />
                                                <PagerStyle BackColor="#ADE6ED" Font-Size="10pt" ForeColor="Blue" HorizontalAlign="Center" />
                                                <AlternatingRowStyle BackColor="Azure" />
                                                <EmptyDataTemplate>
                                                    <table>
                                                        <tr>
                                                            <td style="font-size: 20; color: Red;">
                                                                該寢室未設定告警群...
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </EmptyDataTemplate>
                                            </asp:GridView>
                                        </ContentTemplate>
                                        <Triggers>
                                            <asp:AsyncPostBackTrigger ControlID="btnSet" EventName="Click" />
                                        </Triggers>
                                    </asp:UpdatePanel>
                                </asp:Panel>
                                    </ContentTemplate>
                            </asp:UpdatePanel>
                            </ContentTemplate>
                        </cc1:TabPanel>
                    </cc1:TabContainer>
                </td>
            </tr>
            </table>
    </center>
    </form>
</body>
</html>
